<link rel="stylesheet" type="text/css" href="/Css/uploadify.css">
<link rel="stylesheet" type="text/css" href="/Css/Admin/goods.css">
<script src="/Js/jquery.uploadify.js" type="text/javascript"></script>
<script src="/ckeditor/ckeditor.js" type="text/javascript"></script>

<div class="pad-10">

	<div class="navigate">
		<h1>商品编辑</h1>
		<a class="button fr" href="/index.php/Admin/Goods/">商品列表</a>
  	</div>
  	
<div class="col-tab">
<ul class="tabBut cu-li">
	<li id="tab_setting_1" class="on"
		onclick="SwapTab('setting','on','',2,1);">商品编辑</li>
</ul>


<div id="div_setting_1" class="contentList pad-10">
<table width="100%" cellpadding="2" cellspacing="1" class="table_form">
	<tr>
		<th>商品编号:</th>
		<td>{$goods.id}</td>
	</tr>
    <tr>
        <th>商品分类：</th>
        <td>
			<select name="cate_id" id="cate_id" style="width:150px;">
				<option value="0" selected="selected">--顶级分类--</option>
				<volist name="cates" id="c">
				<option value="{$c.id}" <if condition="$c['id'] eq $goods['cate_id']"> selected="selected"</if> >{$c.name}</option>
				</volist>
	       	</select>
       </td>
	</tr>
	<tr>
		<th width="100">商品名称:</th>
		<td>
			<input type="text" name="name" id="name" class="input-text" value="{$goods.name}" style="width:300px;" />
		</td>
	</tr>
    <tr> 
        <th width="100">商品英文名称 :</th>
        <td><input type="text" name="ename" id="ename" class="input-text" value="{$goods.ename}" style="width:300px;"></td>
    </tr>
	<tr>
		<th width="100">简单描述 :</th>
		<td>
			<textarea id="describe" cols="80" rows="2">{$goods.describe}</textarea>
		</td>
	</tr>
	<tr>
		<th width="100">英文简单描述 :</th>
		<td>
			<textarea id="edescribe" cols="80" rows="2">{$goods.edescribe}</textarea>
		</td>
	</tr>
	<tr>
		<th width="100">产品故事 :</th>
		<td>
			<textarea id="story" cols="80" rows="2">{$goods.story}</textarea>
		</td>
	</tr>
	<tr>
		<th width="100">商品详情 :</th>
		<td>
			<textarea id="detail" rows="8" cols="80">{$goods.detail}</textarea>
			<script type="text/javascript">
				var editor = CKEDITOR.replace("detail");
			</script>
		</td>
	</tr>
	<tr>
		<th width="100">温馨提示 :</th>
		<td>
			<textarea id="tips" name="tips" cols="80" rows="2">{$goods.tips}</textarea>
		</td>
	</tr>
	<tr>
		<th width="100">商品单价:</th>
		<td>
			<p>
			单价: <input type="text" id="price" name="price" value="{$goods.price}" />
			</p>
			
			<div id="div-attrs">
				<include file="Goods:goods_attr" />
			</div>
		
		
		</td>
	</tr>
	 <tr>
		<th width="100">数量单位:</th>
		<td><input type="text" id="unit" name="unit" title="例如:1个，1套，1瓶" value="{$goods.unit}" /></td>
	 </tr>
    <tr>
    	<th>商品图片 :</th>
      <td>
      	<div id="div-thumb"></div>
      </td>
    </tr>  
    <tr>
    	<th>图片上传 :</th>
      <td>
      	<div id="queue"></div>
		<input id="image" name="image" type="file" multiple="false">
      </td>
    </tr> 
	<tr>
		<th width="100">小图编号:</th>
		<td>
			<input type="text" id="image_small" name="image_small" value="{$goods.image_small}" />
			(例如:图片-26,就填写 26 即可)
		</td>
	</tr>
	<tr>
		<th width="100">排序:</th>
		<td><input type="text" id="ord" name="ord" value="{$goods.ord}" /></td>
	</tr>
	
	<tr>
		<th width="100">产品推荐:</th>
		<td>
			<input type="radio" id="is_recommend_0" name="is_recommend" value="0"<eq name="goods.is_recommend" value="0"> checked="checked"</eq> /> 
			<label for="is_recommend_0">否</label> 
			<input type="radio" id="is_recommend_1" name="is_recommend" value="1"<eq name="goods.is_recommend" value="1"> checked="checked"</eq> /> 
			<label for="is_recommend_1">是</label>
		</td>
	</tr>
	<tr>
		<th width="100">明星产品:</th>
		<td>
			<input type="radio" id="is_star_0" name="is_star" value="0"<eq name="goods.is_star" value="0"> checked="checked"</eq> /> 
			<label for="is_star_0">否</label> 
			<input type="radio" id="is_star_1" name="is_star" value="1"<eq name="goods.is_star" value="1"> checked="checked"</eq> /> 
			<label for="is_star_1">是</label>
		</td>
	</tr>
	
	<tr>
		<th width="100">购物车选购:</th>
		<td>
			<input type="radio" id="is_cart_0" name="is_cart" value="0"<eq name="goods.is_cart" value="0"> checked="checked"</eq> /> 
			<label for="is_cart_0">否</label> 
			<input type="radio" id="is_cart_1" name="is_cart" value="1"<eq name="goods.is_cart" value="1"> checked="checked"</eq> /> 
			<label for="is_cart_1">是</label>
		</td>
	</tr>
	<tr>
		<th width="100">产品推荐:</th>
		<td>
		
			<input type="checkbox" id="is_hot" name="is_hot" value="is_hot" <eq name="goods.is_hot" value="1"> checked="checked"</eq> /> 
			<label for="is_hot">热卖</label> 

			<input type="checkbox" id="is_children" name="is_children" value="is_children" <eq name="goods.is_children" value="1"> checked="checked"</eq> /> 
			<label for="is_children">儿童</label>
			
			<input type="checkbox" id="is_birth" name="is_birth" value="is_birth" <eq name="goods.is_birth" value="1"> checked="checked"</eq> /> 
			<label for="is_birth">生日</label>
			
			<input type="checkbox" id="is_lover" name="is_lover" value="is_lover" <eq name="goods.is_lover" value="1"> checked="checked"</eq> /> 
			<label for="is_lover">情人节</label>
				
			<input type="checkbox" id="is_party" name="is_party" value="is_party" <eq name="goods.is_party" value="1"> checked="checked"</eq> /> 
			<label for="is_party">聚会</label>
			
			
			<input type="checkbox" id="is_afternoon_tea" name="is_afternoon_tea" value="is_afternoon_tea" <eq name="goods.is_afternoon_tea" value="1"> checked="checked"</eq> /> 
			<label for="is_afternoon_tea">下午茶</label>
			
			
			<input type="checkbox" id="is_wedding" name="is_wedding" value="is_wedding" <eq name="goods.is_wedding" value="1"> checked="checked"</eq> /> 
			<label for="is_wedding">婚礼</label>
			
			
			<input type="checkbox" id="is_celebration" name="is_celebration" value="is_celebration" <eq name="goods.is_celebration" value="1"> checked="checked"</eq> /> 
			<label for="is_celebration">宴会庆典</label>
			
		</td>
	</tr>
	<tr>
		<th width="100">创建时间:</th>
		<td>{$goods.created}</td>
	</tr>
</table>
</div>

<div class="bk15"></div>
<div class="btn"><input type="button" class="button" value="保存修改" id="btnSave" />
</div>
</div>
</div>


<input type="hidden" id="hd_id" value="{$goods.id}" />
<script type="text/javascript" src="/Js/adm/goods/detail.js"></script>
<script type="text/javascript">
		
$(function() {
	//显示相册
	$('#div-thumb').load('/index.php/Admin/Goods/thumb?id={$goods.id}');
	//上传
	$('#image').uploadify({
		'formData'     : {
			'timestamp' : '{$time}',
			'token'     : '{$token}',
			'goods_id'	: {$goods.id}
		},
		'swf'      : '/Img/upload/uploadify.swf',
		'uploader' : '/index.php/Admin/Goods/image_upload',
		'onUploadComplete' : function(file) {
			//alert('The file ' + file.name + ' finished processing.');
			$('#div-thumb').load('/index.php/Admin/Goods/thumb?id={$goods.id}');
		}
	});


	
});

function goodsImgDel(id){
	
	if(!confirm('确认要删除？')){
		return false;
	}
	
	$.get('/index.php/Admin/Goods/image_del',{'id':id},function(data){
		if(data.success){
			$('#li_' + id).remove();
		}else{
			alert('图片删除失败');
		}
	},'json');
}
</script>